package com.mc.web.controller.fil;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mc.common.annotation.Log;
import com.mc.common.core.controller.BaseController;
import com.mc.common.core.domain.AjaxResult;
import com.mc.common.enums.BusinessType;
import com.mc.fil.domain.FilMachiningOrder;
import com.mc.fil.service.IFilMachiningOrderService;
import com.mc.common.utils.poi.ExcelUtil;
import com.mc.common.core.page.TableDataInfo;

/**
 * 加工中心订单 Controller
 *
 * @author mc
 * @date 2021-04-13
 */
@RestController
@RequestMapping("/fil/order")
public class FilMachiningOrderController extends BaseController
{
    @Autowired
    private IFilMachiningOrderService filMachiningOrderService;

    /**
     * 查询加工中心订单 列表
     */
    @PreAuthorize("@ss.hasPermi('fil:order:list')")
    @GetMapping("/list")
    public TableDataInfo list(FilMachiningOrder filMachiningOrder)
    {
        startPage();
        List<FilMachiningOrder> list = filMachiningOrderService.selectFilMachiningOrderList(filMachiningOrder);
        return getDataTable(list);
    }

    /**
     * 导出加工中心订单 列表
     */
    @PreAuthorize("@ss.hasPermi('fil:order:export')")
    @Log(title = "加工中心订单 ", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FilMachiningOrder filMachiningOrder)
    {
        List<FilMachiningOrder> list = filMachiningOrderService.selectFilMachiningOrderList(filMachiningOrder);
        ExcelUtil<FilMachiningOrder> util = new ExcelUtil<FilMachiningOrder>(FilMachiningOrder.class);
        return util.exportExcel(list, "order");
    }

    /**
     * 获取加工中心订单 详细信息
     */
    @PreAuthorize("@ss.hasPermi('fil:order:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(filMachiningOrderService.selectFilMachiningOrderById(id));
    }

    /**
     * 新增加工中心订单
     */
    @PreAuthorize("@ss.hasPermi('fil:order:add')")
    @Log(title = "加工中心订单 ", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FilMachiningOrder filMachiningOrder)
    {
        return toAjax(filMachiningOrderService.insertFilMachiningOrder(filMachiningOrder));
    }

    /**
     * 修改加工中心订单
     */
    @PreAuthorize("@ss.hasPermi('fil:order:edit')")
    @Log(title = "加工中心订单 ", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FilMachiningOrder filMachiningOrder)
    {
        return toAjax(filMachiningOrderService.updateFilMachiningOrder(filMachiningOrder));
    }

    /**
     * 删除加工中心订单
     */
    @PreAuthorize("@ss.hasPermi('fil:order:remove')")
    @Log(title = "加工中心订单 ", businessType = BusinessType.DELETE)
    @DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable String id)
    {
        return toAjax(filMachiningOrderService.deleteFilMachiningOrderById(id));
    }
}